<#macro page id='_page_navigate' recordCount=0 pageSize=4 reset=false formId="forms[0]" vvshopCss=false>

<#if !currPage?exists>

<#if !reset>
<#assign currPage=((stack.findString("#parameters['currPage']"))?default('1'))?number/>
<#else>
<#assign currPage=1/>
</#if>

</#if>

<#if (recordCount < 1) >
	<#return>
</#if>

<#if (recordCount%pageSize)?int!=0>
   <#assign totalPage=(recordCount/pageSize)?int+1/>
<#else>
   <#assign totalPage=(recordCount/pageSize)?int/>
</#if>
<#if (currPage > totalPage) >
   <#assign currPage=totalPage/>
</#if>

共 <font color="red">#{recordCount}</font> 条记录

<font color="red">#{currPage}</font>/<font color="red">#{totalPage}</font>
<#if !vvshopCss>
	<#if (currPage > 1) >
		<a href="javascript:go('0','#{pageSize}','#{1}');">
	</#if>第一页<#if (currPage > 1) ></a>
	</#if>
<#else>
	<#if (currPage > 1) >
		<a class="next" href="javascript:go('0','#{pageSize}','#{1}');">第一页
		</a>
	</#if>
</#if>

<#if !vvshopCss>
	<#if (currPage > 1) >
	<#assign prefirstResult=(currPage-2)*pageSize/>
	<a href="javascript:go('#{prefirstResult}','#{pageSize}','#{currPage-1}');">
	</#if>上一页<#if (currPage > 1) ></a>
	</#if>
<#else>
	<#if (currPage > 1) >
		<#assign prefirstResult=(currPage-2)*pageSize/>
		<a href="javascript:go('#{prefirstResult}','#{pageSize}','#{currPage-1}');">上一页
		</a>
	</#if>
</#if>
<#if (currPage>5)>
	<#assign pIndex=(currPage-5) />

	<#assign nIndex=(currPage+5) />
	<#if (nIndex>totalPage)>
	<#assign nIndex=totalPage />
	</#if>
<#else>
	<#assign pIndex=1 />
	<#assign nIndex=11 />
	<#if (nIndex>totalPage)>
	<#assign nIndex=totalPage />
	</#if>
</#if>
<#if (currPage!=1)>
<#list pIndex..currPage-1 as x>
	<a href="javascript:go('#{(x-1)*pageSize}','#{pageSize}','#{x}');">#{x}</a>
</#list>
</#if>

	

<#if vvshopCss>
	<span class="page_now">#{currPage}</span>
	<span style="display:none">homevv</span>
<#else>
	<font color="red"><u>#{currPage}</u></font>
</#if>
	
<#if (currPage!=totalPage)>
<#list (currPage+1)..nIndex as x>
   <a href="javascript:go('#{(x-1)*pageSize}','#{pageSize}','#{x}');">#{x}</a>
</#list>
</#if>
<#if !vvshopCss>
	<#if (currPage < totalPage) >
	<#assign nextfirstResult=(currPage)*pageSize/>
	<a href="javascript:go('#{nextfirstResult}','#{pageSize}','#{currPage+1}');">
	</#if>下一页<#if (currPage < totalPage) ></a>
	</#if>
<#else>
	<#if (currPage < totalPage) >
	<#assign nextfirstResult=(currPage)*pageSize/>
	<a class=next href="javascript:go('#{nextfirstResult}','#{pageSize}','#{currPage+1}');">
	下一页</a>
	</#if>
</#if>

<#if !vvshopCss>
	<#if (currPage < totalPage) >
	<a href="javascript:go('#{(totalPage-1)*pageSize}','#{pageSize}','#{totalPage}');">
	</#if>最后一页<#if (currPage < totalPage) ></a>
	</#if>
<#else>
	<#if (currPage < totalPage) >
		<a class=next href="javascript:go('#{(totalPage-1)*pageSize}','#{pageSize}','#{totalPage}');">
		最后一页</a>
	</#if>
</#if>
<script>
function go(firstResult,maxResults,currPage){
   document.getElementById('firstResult').value = firstResult;
   document.getElementById('maxResults').value = maxResults;
   document.getElementById('currPage').value = currPage;
   try{
   	if(document.getElementById('pid') != null)
   		document.getElementById('pid').value="";
   }catch(e){}




   document.${formId?if_exists}.submit();
}

<#if formId?exists && formId!="forms[0]">
   	j('#${formId?if_exists}').append("<input type='hidden' id='recordCount' name='recordCount' value='#{recordCount?default(0)}'>");
   	j('#${formId?if_exists}').append("<input type='hidden' id='totalPage' name='totalPage' value='#{totalPage?default(0)}'>");
   	j('#${formId?if_exists}').append("<input type='hidden' id='currPage' name='currPage' value='#{currPage?default(0)}'>");
   	j('#${formId?if_exists}').append("<input type='hidden' id='firstResult' name='firstResult' value='#{(currPage-1)*pageSize}'>");
   	j('#${formId?if_exists}').append("<input type='hidden' id='maxResults' name='maxResults' value='#{pageSize}'>");
</#if>

<#if formId?exists && formId="forms[0]">
function writeHidden(){
	if(document.getElementById('recordCount') == null){
		document.write("<input type='hidden' id='recordCount' name='recordCount' value='#{recordCount?default(0)}'>");
		//alert("<input type='hidden' id='recordCount' name='recordCount' value='#{recordCount?default(0)}'>");
	}
	if(document.getElementById('totalPage') == null){
		document.write("<input type='hidden' id='totalPage' name='totalPage' value='#{totalPage?default(0)}'>");
		//alert("<input type='hidden' id='totalPage' name='totalPage' value='#{totalPage?default(0)}'>");
	}
	if(document.getElementById('currPage') == null){
		document.write("<input type='hidden' id='currPage' name='currPage' value='#{currPage?default(0)}'>");
		//alert("<input type='hidden' id='currPage' name='currPage' value='#{currPage?default(0)}'>");
	}
	if(document.getElementById('firstResult') == null){
		document.write("<input type='hidden' id='firstResult' name='firstResult' value='#{(currPage-1)*pageSize}'>");
		//alert("<input type='hidden' id='firstResult' name='firstResult' >");
	}
	if(document.getElementById('maxResults') == null){
		document.write("<input type='hidden' id='maxResults' name='maxResults' value='#{pageSize}'>");
		//alert("<input type='hidden' id='maxResults' name='maxResults' >");
	}
}
writeHidden();
</#if>
</script>

</#macro>


